﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Http;

namespace MvcApplication6
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

            

            routes.MapRoute(
                name: "NewDetail",
                url: "{controller}/{action}/{Name}/{Id}",
                defaults: new
                {
                    Name = UrlParameter.Optional,
                    Id = UrlParameter.Optional,
                    action = "NewDetail"
                },
                constraints: new
                {
                    controller = "Home"
                }
           );

           // routes.MapRoute(
           //     name: "GetProductByFlg",
           //     url: "{controller}/{action}/{Flag}/{NameP}",
           //     defaults: new
           //     {
           //         NameP = UrlParameter.Optional,
           //         Flag = UrlParameter.Optional,
           //         action = "GetProductByFlg"
           //     },
           //     constraints: new
           //     {
           //         controller = "Home"
           //     }
           //);

            routes.MapRoute(
                name: "product",
                url: "{controller}/{action}/{TitleMenu}/{LevelMenu}/{Ids}/{page}/{MenuId1}/{MenuId2}/{MenuId3}/{NameP}",
                defaults: new { controller = "Home",
                                action = "GetProduct",
                                TitleMenu = UrlParameter.Optional,
                                LevelMenu = UrlParameter.Optional,
                                Ids = UrlParameter.Optional,
                                page = UrlParameter.Optional,
                                MenuId1 = UrlParameter.Optional,
                                MenuId2 = UrlParameter.Optional,
                                MenuId3 = UrlParameter.Optional,
                                NameP = UrlParameter.Optional}
            );

            routes.MapRoute(
                name: "productDetail",
                url: "{controller}/{action}/{ProductName}/{LevelMenu1}/{Ids}/{MenuId1}/{MenuId2}/{MenuId3}",
                defaults: new { controller = "Home",
                                action = "ProductDetail",
                                ProductName = UrlParameter.Optional,
                                LevelMenu = UrlParameter.Optional,
                                Ids = UrlParameter.Optional,
                                MenuId1 = UrlParameter.Optional,
                                MenuId2 = UrlParameter.Optional,
                                MenuId3 = UrlParameter.Optional}
            );

            routes.MapRoute(
            name: "asdasd",
            url: "{controller}/{action}/{nameEvent}/{idss}",
            defaults: new
                {
                    controller = "Home",
                    action = "TinTuc",
                    nameEvent = UrlParameter.Optional,
                    idss = UrlParameter.Optional
                }
            );
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
            //To:DO
        }
    }
}